<%-- 
    Document   : WishList
    Created on : 9-apr-2010, 15.48.59
    Author     : Rachid Ouchary, Fabio Strocco, Max Passaghe, Marco Tansini.
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" import="java.util.*" import="entity.*" import="servlet.ServletUtil"%>
<script type="text/javascript" src="javascript/scroll.js"></script>
<div id="col3">
    <div id="col3_content" class="clearfix">
        <div id="header_title"><p class="txHeader">Benvenuto nel sito di Wishlist</p><br />
        </div>
        <div id="main_content">
            <img src="images/div_centrale_top.png" width="526" height="18" />
            <h1>Wish List</h1>
            <table width="496" class="tableItemList" >
                <%
                            Collection<Wish> wishList = (Collection<Wish>) request.getAttribute(ServletUtil.PARAM_WISHLIST);
                            Map<Long, String> resultList = (Map<Long, String>) request.getAttribute(ServletUtil.PARAM_EBAY_RESULTS);
                            final boolean isUserWL = (Boolean) request.getAttribute(ServletUtil.PARAM_IS_USER_WISHLIST);

                            for (Wish wish : wishList) {
                %>
                <tr>
                    <td width="36" rowspan="2" class="tdBull"><img src="images/bull.png" width="22" height="20" /></td>
                    <td colspan="3"><span class="categoria">CATEGORIA: <%=wish.getItem().getCategoria().getCatName().toUpperCase()  %></span><br />
                        <span class="descrizione"><%=wish.getItem().getDescrizione()%></span></td>
                </tr>
                <tr>
                    <td width="142" valign="top"><span class="itemLabel">Voto: </span>
                        <%
                         for (int i = 0; i < wish.getVoto(); i++) {
                        %>
                        <%if(isUserWL){ %><a href="MainDispatcher?operation=<%= ServletUtil.ACTION_MODIFICA_DESIDERIO%>&<%=ServletUtil.PARAM_WISH_ID%>=<%=wish.getId()%>&<%=ServletUtil.PARAM_PRIORITY%>=<%=wish.getPriority()%>&<%=ServletUtil.PARAM_VOTO%>=<%=i + 1%>"><%}%>
                            <img src="images/star.png" class="star"/>
                        </a>
                         <%if(isUserWL){ %><%}%><%}%>

                        <%
                        for (int i = wish.getVoto(); i < 5; i++) {
                        %>
                         <%if(isUserWL){ %><a href="MainDispatcher?operation=<%= ServletUtil.ACTION_MODIFICA_DESIDERIO%>&<%=ServletUtil.PARAM_WISH_ID%>=<%=wish.getId()%>&<%=ServletUtil.PARAM_PRIORITY%>=<%=wish.getPriority()%>&<%=ServletUtil.PARAM_VOTO%>=<%=i + 1%>"><%}%>
                            <img src="images/star_off.png" class="star" />
                         <%if(isUserWL){ %></a><%}%>
                        <%}%>

                    </td>

                    <td width="156" valign="top">
                        <form action="MainDispatcher?operation=<%= ServletUtil.ACTION_PRENOTA%>" method="post" name="prenota" target="_self">
                        <span class="itemLabel">Prenotato: </span>
                            <% if(wish.isPrenotato()){%>
                            <img src="images/pren_si.png" class="star"/>
                            <%}else{%>
                            <img src="images/pren_no.png" class="star"/>
                            <%}%>
                            <%if(!wish.isPrenotato() && ServletUtil.isLogged(session) ) {%>
                            <input class="textbutton" name="prenota" type="submit" value="(prenota)" />
                            <input type="hidden" name="<%= ServletUtil.PARAM_WISH_ID%>" value="<%= wish.getId()%>"/>
                            <%}%>
                        </form>
                    </td>

                    <td width="142" valign="top"><span class="itemLabel">Priorità: </span>
                        <%
                         for (int i = 0; i < wish.getPriority(); i++) {
                        %>
                         <%if(isUserWL){ %><a href="MainDispatcher?operation=<%= ServletUtil.ACTION_MODIFICA_DESIDERIO%>&<%=ServletUtil.PARAM_WISH_ID%>=<%=wish.getId()%>&<%=ServletUtil.PARAM_PRIORITY%>=<%=i + 1%>&<%=ServletUtil.PARAM_VOTO%>=<%=wish.getVoto()%>"><%}%>
                            <img src="images/heart.png"/>
                         <%if(isUserWL){ %></a><%}%>
                        <%}%>

                        <%
                        for (int i = wish.getPriority(); i < 5; i++) {
                        %>
                         <%if(isUserWL){ %><a href="MainDispatcher?operation=<%= ServletUtil.ACTION_MODIFICA_DESIDERIO%>&<%=ServletUtil.PARAM_WISH_ID%>=<%=wish.getId()%>&<%=ServletUtil.PARAM_PRIORITY%>=<%=i + 1%>&<%=ServletUtil.PARAM_VOTO%>=<%=wish.getVoto()%>"><%}%>
                            <img src="images/heart_off.png"/>
                         <%if(isUserWL){ %></a><%}%>
                        <%}%>
                        </td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td colspan="3">

                        <div class="dhtmlgoodies_question">Acquista su Ebay</div>
                        <div class="dhtmlgoodies_answer">
                            <div><p>
                                    <%= resultList.get(wish.getItem().getId())%>
                                </p>
                            </div>
                        </div>
                        <%if(!isUserWL && session.getAttribute(ServletUtil.SESSION_UTENTE) != null) { %>
                        <form action="MainDispatcher?operation=<%= ServletUtil.ACTION_AGGIUNGI_DESIDERIO%>" method="post" target="_self">
                            <%Item item = wish.getItem();%>
                            <input type="hidden" name="<%= ServletUtil.PARAM_ITEM_ID%>" value="<%= item.getId()%>"/>
                            <input type="hidden" name="<%= ServletUtil.PARAM_PRIORITY%>" value="<%= wish.getPriority()%>"/>
                            <input type="hidden" name="<%= ServletUtil.PARAM_VOTO%>" value="<%= wish.getVoto()%>"/>
                            <input type="hidden" name="<%= ServletUtil.PARAM_WISHLISTOWNER%>" value="<%= wish.getUtente().getUsername()%>"/>
                            <input name="agg" type="image" value="agg" src="images/agg_wishlist_txt.png" />
                        </form>
                        <%}%>
                        <br/>
                        <br/>
                    </td>
                </tr>
                <%}%>
            </table>
            <img src="images/div_centrale_bottom.png" width="526" height="12" />
        </div>
    </div>
    <!-- IE Column Clearing -->
    <div id="ie_clearing"> &#160; </div>
</div>